﻿myApp.directive('navList', function ($location, $rootScope) {
    return {
        restrict: 'E',
        template: '<nav class="nav nav-tabs navbar-fixed-top swiper-container thumb" role="tablist">' +
          '<div class="swiper-wrapper">' +
          '<a ui-sref="home" ui-sref-active="active" role="presentation" style="width:60px;" class="swiper-slide"><span>推荐</span></a>' +
          '<a ui-sref="slgs" ui-sref-active="active" role="presentation" class="swiper-slide posotiontags"><i></i><span>时令果蔬</span></a>' +
          '<a ui-sref="lszb" ui-sref-active="active" role="presentation" class="swiper-slide"><span>滋补零食</span></a>' +
          '<a ui-sref="spxx" ui-sref-active="active" role="presentation" class="swiper-slide"><span>生鲜食品</span></a>' +
          '<a ui-sref="mcjs" ui-sref-active="active" role="presentation" class="swiper-slide"><span>茗茶酒水</span></a>' +
          '<a ui-sref="lygh" ui-sref-active="active" role="presentation" class="swiper-slide"><span>粮油干货</span></a>' +
          '<a ui-sref="jdjj" ui-sref-active="active" role="presentation" class="swiper-slide"><span>家电家居</span></a>' +
          '<a ui-sref="myzq" ui-sref-active="active" role="presentation" class="swiper-slide"><span>母婴专区</span></a>' +
          '<a ui-sref="mzzq" ui-sref-active="active" role="presentation" class="swiper-slide"><span>美妆专区</span></a>' +
          '</div>' +
          '</nav>',
        compile: function (tElement, tAttrs, transclude) {
            return {
                pre: function preLink(scope, element, iAttrs, controller) {
                },
                post: function postLink(scope, element, iAttrs, controller) {
                    var url = $location.url();
                    var sref = url.replace('/', '');
                    var offset = $('a[ui-sref=' + sref + ']', $(element)).offset();
                    if(offset){
                        $('.nav-tabs').scrollLeft(offset.left);
                    }
                }
            }
        },
        //link: function (scope, element) {
            //$rootScope.$on('$locationChangeStart', function(){
 
            //}); 
        //}
    }
})

 myApp.directive('footerList', function () {
      return {
          restrict: 'E',
          template: '<div class="navbar-default navbar-fixed-bottom" id="mypage">' +
          '<ul class="footer shop bootsfootul">' +
          '<li class="item"><a ui-sref="home" " href="index.html" class="active"><div></div><p>首页</p></a></li>' +
          '<li class="item"><a href="/Wap/Shop/CategoryFixed.aspx"><div></div><p>分类</p></a></li>' +
          '<li class="item"><a href="/Wap/ShoppingCart/"><div></div><p>购物车</p></a></li>' +
          '<li class="item"><a href="/wap/shop/MemberDefault.aspx"><div></div><p>我</p></a></li>' +
          '</ul>' +
          '</div>'
      }
  })

  myApp.directive('onFinishRenderFilters', function ($timeout) {
      return {
          restrict: 'A',
          link: function (scope, element, attr) {
              if (scope.$last === true) {
                  $timeout(function () {
                      scope.$emit('ngRepeatFinished', attr);
                  });
              }
          }
      };
  });
